package lanou3g.myfirstapp36kr.activity;

import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ListView;

import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.google.gson.Gson;

import lanou3g.myfirstapp36kr.R;
import lanou3g.myfirstapp36kr.StringUrl;
import lanou3g.myfirstapp36kr.adapter.ActivityFindLookforMoneyLVAdapter;
import lanou3g.myfirstapp36kr.base.BaseActivity;
import lanou3g.myfirstapp36kr.entity.ActivityLookforMoneyEntity;
import lanou3g.myfirstapp36kr.myvolleysingleton.VolleySingleton;

/**
 * Created by dllo on 16/8/7.
 */
public class FindLookForMoneyActivity extends BaseActivity {
    private ListView listView;
    private ActivityFindLookforMoneyLVAdapter adapter;
    @Override
    protected int getLayout() {
        return R.layout.activity_find_loohfor_money;
    }

    @Override
    protected void initView() {
        listView = (ListView) findViewById(R.id.list_view_lookfor_money);
        adapter = new ActivityFindLookforMoneyLVAdapter(this);
        findViewById(R.id.iv_back).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }

    @Override
    protected void initData() {

        //Intent intent = getIntent();
//        ActivityLookforMoneyEntity entity = (ActivityLookforMoneyEntity) intent.getSerializableExtra("entity");
//        Log.d("++++",entity.getData().getData().get(0).getUser().getName());

        VolleySingleton.addRequest(StringUrl.stringFindLookForMoney, ActivityLookforMoneyEntity.class, new Response.Listener<ActivityLookforMoneyEntity>() {
            @Override
            public void onResponse(ActivityLookforMoneyEntity response) {
                adapter.setEntity(response);
                listView.setAdapter(adapter);

            }
        }, new ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                error.getMessage();

            }
        });

    }
}
